/**
 * 笔记api设置
 */
import {spring} from "@/config";
const BASEURL = '/note'
const BASEURL_BASE = '/knowledgeBase'

// 创建笔记
export function postNoteCreateNote(param:{
    noteName:string,
    noteCoverImg:File,
}){
    return spring({
        url:BASEURL+'/createNote',
        method:'post',
        data:param,
        headers:{
            'Content-Type': 'multipart/form-data;charset=UTF-8',
        }
    })
}
// 修改笔记
export function postNoteUpdateNoteByNoteId(param:{
    id:number,
    noteName:string,
    noteCoverImg:File,
    noteContent:string,
}){
    return spring({
        url: BASEURL+'/updateNoteByNoteId',
        method: 'post',
        data: param,
    })
}
// 删除笔记 TODO：试试
export function getNoteDeleteNoteByNoteId(noteId:number){
    return spring({
        url: BASEURL+'/deleteNoteByNoteId/',
        method: 'get',
        params:noteId,
    })
}
//  获取笔记列表 -- 未分组
export function postNoteQueryNote(param:{
    pageNum?:number,
    pageSize?:number,
}){
    return spring({
        url: BASEURL+'/queryNote',
        method: 'post',
        data: param,
    })
}
//  获取所有笔记列表
export function postNoteQueryAllNote(param:{
    pageNum?:number,
    pageSize?:number,
}) {
    return spring({
        url: BASEURL + '/queryAllNote',
        method: 'post',
        data: param,
    })
}
// 查询笔记 -- 按类型
export function postNoteQueryNoteByNoteAbout(param:{
    type?:string,
    typeTime?:number,
    data?:string|number
}){
    return spring({
        url: BASEURL+'/queryNoteByNoteAbout',
        method: 'post',
        data: param,
    })
}
// 浏览笔记
export function postNoteViewNote(noteId:number){
    return spring({
        url: BASEURL + '/viewNote/',
        method: 'get',
        params: noteId,
    })
}
// 知识库模块
// 进行笔记分组
export function postKnowledgeBaseNoteGroup(param:{
    knowledgeBaseId:number,
    noteId:number,
}){
    return spring({
        url: BASEURL_BASE+'/noteGroup',
        method: 'post',
        data: param,
    })
}
// 删除整个分组
export function postKnowledgeBaseDelNoteGroup(noteKnowledgeBaseId:number){
    return spring({
        url: BASEURL_BASE+'/delNoteGroup/',
        method: 'get',
        params: noteKnowledgeBaseId,
    })
}
// 删除分组中的单个笔记
export function postKnowledgeBaseDelNoteGroupItem(param:{
  noteKnowledgeBaseId:number,
  noteId:number
}){
    return spring({
        url: BASEURL_BASE+'/delNoteGroupItem',
        method: 'post',
        data: param,
    })
}
// 创建笔记分组
export function postKnowledgeBaseCreateGroup(param:{
    knowledgebaseName: string,
    knowledgebaseIntro: string,
    type:string|undefined
}){
    return spring({
        url: BASEURL_BASE+'/createGroup',
        method: 'post',
        data: param,
    })
}
// 获取分组列表
export function postKnowledgeBaseSelectGroup(param:{
    pageNum?:number,
    pageSize?:number,
}){
    return spring({
        url: BASEURL_BASE+'/selectGroup',
        method: 'post',
        data: param,
    })
}
// 获取分组下的笔记
export function postKnowledgeBaseSelectGroupById(param:{
    pageNum?:number,
    pageSize?:number,
    id:number|null, // 知识库id
}){
    return spring({
        url: BASEURL_BASE+'/selectGroupById',
        method: 'post',
        data: param,
    })
}
